#ifndef _ROT_H_
#define _ROT_H_

#include "stdafx.h"

class CRotImpl : public IRot, public CUnknownImp
{
public:
    CRotImpl(void);
    ~CRotImpl(void);

public:
    BEGIN_STDCOM_MAP
    STDCOM_INTERFACE_ENTRY_UNKNOWN_(IRot)
    STDCOM_INTERFACE_ENTRY(IRot)
    END_STDCOM_MAP

public:
    // IRot
    std_method(CreateInstance)(REFCLSID clsid, IBase* punk, REFIID iid, void** ppv);
    std_method(Register)(REFCLSID clsid, LPCSTR progid, IBase* punk, ULONG id);
    std_method(Revoke)(REFCLSID clsid);
    std_method(IsRunning)(REFCLSID clsid);
    std_method(GetObject)(REFCLSID clsid, REFIID iid, IBase** ppunk);
    std_method(RevokeAll)();
    std_method_(LPCSTR, ProgIDFromCLSID)(REFCLSID clsid);
    std_method_(CLSID, CLSIDFromProgID)(LPCSTR progid);
    std_method_(ULONG, GetObjectCount)();

private:
    std_method(GetBaseObject)(REFCLSID clsid, REFIID iid, IBase** ppunk);

private:
    typedef struct tagRotItem {
        string progid;
        CLSID cls;
        _lComPtr<IBase> m_ptr;
        ULONG index;
    } RotItem;

    typedef std::map<GUID, RotItem, clscmp> OBJMAP;
    OBJMAP m_map;
    CAutoLock m_lock;
};

#endif
